﻿/* Pomoho form check - Manage */
/* Created By onMax 2008-10-24 11:41:42 */

function $$(Obj){
 		 return document.getElementById(Obj);
}
Pui.checkform={
	checkinput:function (type){
		var sProgramName = $$("txtProgramName").value;
		var sProgramDesc =$$("txtProgramInfo").value;
		var sProgramTag = $$("txtProgramTag").value; 
		var sProgramInfo = $$("txtProgramInfo").value;
		var programorder = $$("txtOrder").value;
		if ( sProgramName=="" ){
			//alert( "请输入新专栏的名称" );
			Pui.manage.MsgDiv(1,'提示','请输入新专辑的名称','$$("txtProgramName").focus();');
			return false;				
		}
		if ( sProgramName.length>16 ){
			Pui.manage.MsgDiv(1,'提示','新专辑的名称不能超过16个字','$$("txtProgramName").focus();');
			return false;				
		}
		if( sProgramTag == "" ){
			Pui.manage.MsgDiv(1,'提示','标签不可以为空，多个标签用逗号隔开，如“搞笑,原创”，合适的标签，可以让更多的人关注你的视频！','$$("txtProgramTag").focus();');
			return false;	
		}
		if( sProgramTag.length>16 ){
			Pui.manage.MsgDiv(1,'提示','标签的名称不能超过16个字','$$("txtProgramTag").focus();');
			return false;		
		}
		if( sProgramInfo == "" ){
			Pui.manage.MsgDiv(1,'提示','专辑简介不可以为空！','$$("txtProgramInfo").focus();');
			return false;	
		}
		if( sProgramInfo.length>36 ){
			Pui.manage.MsgDiv(1,'提示','专辑简介不能超过36个字','$$("txtProgramInfo").focus();');
			return false;		
		}
		if ( type =="a" ){				
			if( programorder != "" ){
				if ( !this.checkNum(programorder) ){
					Pui.manage.MsgDiv(1,'提示','专辑排序必须为数字并且大于或等于0，最大为100','$$("txtOrder").focus();');
					return false;	
				}
				else 
				{
					if ( programorder > 100 )
					{
						Pui.manage.MsgDiv(1,'提示','专辑排序必须为数字并且大于或等于0，最大为100','$$("txtOrder").focus();');
						return false;	
					}
				}
			}
		}
		if ( type =="x" ){
			if( programorder == "" ){
				Pui.manage.MsgDiv(1,'提示','专辑排序不可以为空！','$$("txtOrder").focus();');
				return false;	
			}else{
				if ( !this.checkNum(programorder) ){
					Pui.manage.MsgDiv(1,'提示','专辑排序必须为数字并且大于或等于0，最大为100','$$("txtOrder").focus();');
					return false;	
				}
				else
				{
					if ( programorder > 100 )
					{
						Pui.manage.MsgDiv(1,'提示','专辑排序必须为数字并且大于或等于0，最大为100','$$("txtOrder").focus();');
						return false;	
					}
				}
			}
		}
		return true;
	},
	
	
	checkNum:function (InputValue){
		var reg=/^([0-9])+$/
		var isValid
		isValid=reg.exec(InputValue)
		if (!isValid) {
			return false
		}
		return true
	},		
				
	canceled:function (){
		$$("MySpecial").style.display="none";
	},
					
	//删除专栏
	f_deleteprograms:function ( iProgramID ){
		//if ( confirm("你确定要删除该分类吗？")==false )
		Pui.manage.MsgDiv(2,'提示','你确定要删除该分类吗？','Pui.checkform.f_delsuc('+iProgramID+')');
		//return;
				
	},		
	f_delsuc:function(iProgramID){
		//$$("deleteP").style.display="";
		$$("hid_id").value=iProgramID;
		//$$("deleteP").click();
		$$("formMain").submit();
		alert(1)
	},			
	f_Eidtprograms:function (programid,programname,programdesc,programtags,ordernum){
		$$("MySpecial").style.display="";
		$$("txtProgramName").value=programname;
		$$("txtProgramTag").value=programtags;
		$$("txtProgramInfo").value=programdesc;
		$$("txtOrder").value=ordernum;
		$$("save").style.display="none";
		$$("xiugai").style.display="";
		$$("hid_id").value=programid; 
		$$("txtProgramInfo").focus();
		
	},
	f_showHotTags:function (){
		managezl.GetHotTags(Pui.checkform.callback_hotTags);
		//this.callback_hotTags({error:null,value:1111})
	},
	callback_hotTags:function (res){
		if(res.error!=null){
			alert(res.error);
		}else{  
			$$("itags").style.display="";
			var td = $$("itags");
			if( td.childNodes.length>0 ){
				td.removeChild( td.firstChild );
			}
			var div = document.createElement("DIV");
			div.innerHTML = res.value;
			td.appendChild( div );
		}
	},
	f_managereprogramsshow:function (){
		$$("a_li").className="s1";
		$$("m_li").className="s2 ac";
		$$("MySpecialList").style.display="";
		$$("MySpecial").style.display="none";
		$$("bnt_canle").style.display="";
	},
	//显示添加输入区
	f_addprogramsshow:function (){
		$$("bnt_canle").style.display="none";
		$$("save").style.display="";
		$$("xiugai").style.display="none";
		$$("txtProgramName").value="";
		$$("txtProgramTag").value="";
		$$("txtProgramInfo").value="";
		$$("txtOrder").value="";
		$$("a_li").className="s2 ac";
		$$("m_li").className="s1";
		$$("MySpecial").style.display="";
		$$("MySpecialList").style.display="none";
	},
	f_gettags:function ( tags ){
		if ($$("txtProgramTag").value != "" ){
			if ($$("txtProgramTag").value.indexOf(tags)==-1){
				$$("txtProgramTag").value = $$("txtProgramTag").value+","+tags;
			}					
		}else{
			$$("txtProgramTag").value = tags;
		}
	}

}
				